//
//  TableViewCell.m
//  bigtableview
//
//  Created by GripMeMory on 16/1/7.
//  Copyright © 2016年 GripMeMory. All rights reserved.
//

#import "BigTableViewLeftCell.h"

@interface BigTableViewLeftCell ()

{
    NSMutableArray *_labelArray;
}

@end

@implementation BigTableViewLeftCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)layoutSubviews{
    
    for (UILabel *label in _labelArray) {
        label.frame = CGRectMake(label.tag * 150, 0, 150, self.height);
    }
}

- (void)configureWithModal:(BigTableViewModal *)modal{
    _labelArray = [[NSMutableArray alloc] initWithCapacity:10];
    [_labelArray removeAllObjects];
    [self removeAllSubviews];
    for (int i = 0; i < modal.contentArray.count; i++) {
        UILabel *label = [[UILabel alloc] init];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = modal.contentArray.firstObject;
        label.tag = i;
        [self addSubview:label];
        [_labelArray addObject:label];
    }
    switch (modal.state) {
        case JMJBidingStateHaveOffered:
            [self setLabelColor: [UIColor redColor]];
            break;
        case JMJBidingStateNotBid:
            [self setLabelColor: [UIColor greenColor]];
            break;
        case JMJBidingStatePriceChange:
            [self setLabelColor: [UIColor yellowColor]];
            break;
        case JMJBidingStateMyBid:
            [self setLabelColor: [UIColor blueColor]];
            break;
        default:
            break;
    }
}

- (void)setLabelColor:(UIColor *)color{
    for (UILabel *label in _labelArray) {
        label.textColor = color;
    }
}

@end
